using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using WorkTracker.BusinessObjects;

namespace WorkTracker
{
	/// <summary>
	/// Displays user editing form. Currently it only adds a user to the database.
	/// </summary>
	public partial class UserEditForm : Form
	{
		#region Properties

		/// <summary>
		/// User.
		/// </summary>
		public User User {
			get { return _user; }
			set { _user = value; }
		}
		private User _user;

		#endregion

		/// <summary>
		/// Constructor.
		/// </summary>
		public UserEditForm() {
			InitializeComponent();
			this.lblUserName.Text = Environment.UserName;
		}

		private void lblSave_Click(object sender, EventArgs e) {
			if (User == null) {
				User = new User();
				User.Name = this.lblUserName.Text;
				User.WorkHoursPerDay = (float)this.nudWorkHours.Value;
				DataAccessLayer.InsertUser(User);
				this.DialogResult = DialogResult.OK;
				this.Close();
			}
		}
	}
}